﻿using LaserMark.DataAccess.Models;

namespace LaserMark.DataAccess.Service
{
    public class PhotoelectricityService : IPhotoelectricityService
    {
        private IDBManager DBManager { get; set; }

        public PhotoelectricityService(IDBManager dBManager)
        {
            DBManager = dBManager;
        }

        public async Task<PhotoelectricitySetting> Get()
        {
            using var db = DBManager.Create();

            return await db.SingleAsync<PhotoelectricitySetting>("where Id = 1");
        }

        public async Task<bool> Update(PhotoelectricitySetting model)
        {
            using var db = DBManager.Create();
            return (await db.UpdateAsync(model)) > 0;
        }
    }
}
